package com.etop.basic.controller;

import org.jboss.logging.Logger;
import org.springframework.ui.Model;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

public class BaseController {
    public final static String ERROR="error";
    public final static String SUCCESS="success";
    protected Logger log=Logger.getLogger(this.getClass());
    
    /**
     * 添加model消息
     * @param messages 
     */
    protected void addMessage(Model model,String messages){
    	model.addAttribute("message", messages);
    }
    /**
     * 添加model消息
     * @param type 消息类型
     * @param messages 
     */
    protected void addMessage(Model model,String type,String messages){
    	model.addAttribute("message", messages);
    	model.addAttribute("type", type);
    }
    /**
     * 添加flash消息
     * @param redirectAttributes
     *        重定向时带的参数
     * @param messages
     *        
     */
    public void addMessage(RedirectAttributes redirectAttributes,String messages){
    	redirectAttributes.addFlashAttribute("message", messages);
    }
     /**
      * 添加Falsh消息
      */
    public void addMessage(RedirectAttributes redirectAttributes,String type,String messages){
    	redirectAttributes.addFlashAttribute("type", type);
    	redirectAttributes.addFlashAttribute("message", messages);
    }
}
